﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Web.Http;
using GooglePlaces;
using GooglePlaces.Queries;
using Newtonsoft.Json;




namespace SmartTravelAssistant.Controllers
{
    public class PlacesController : ApiController
    {
        [HttpGet]
        public RootObject NearbySearch()
        {
            //lat=47.1569444, lng=27.5902778
            RootObject result = JsonConvert.DeserializeObject<RootObject>(new PlaceSearchApi().NearbySearch(new PlaceSearchQuery { Sensor = "false", Radius = "50000", Location = "47.1569444,27.5902778" }));
            return result;
        }

        [HttpGet]
        public object TextSearch()
        {
            var result = JsonConvert.DeserializeObject<object>(new PlaceSearchApi().TextSearch(new PlaceSearchQuery { Sensor = "false", Radius = "50000", Query = "pizza iasi" }));
            return result;
        }

        [HttpGet]
        public object PlaceDetails()
        {
            var result = JsonConvert.DeserializeObject<object>(new PlacesDetailsApi().PlaceDetails(new PlaceDetailsQuery { Reference = "CmRYAAAAciqGsTRX1mXRvuXSH2ErwW-jCINE1aLiwP64MCWDN5vkXvXoQGPKldMfmdGyqWSpm7BEYCgDm-iv7Kc2PF7QA7brMAwBbAcqMr5i1f4PwTpaovIZjysCEZTry8Ez30wpEhCNCXpynextCld2EBsDkRKsGhSLayuRyFsex6JA6NPh9dyupoTH3g", Sensor = "false", }));
            return result;
        }

        [HttpGet]
        public object PlacePhoto()
        {
            var result = JsonConvert.DeserializeObject<object>(new PlacePhotosApi().PlacePhoto(new PlacePhotoQuery { Maxwidth = "400", Photoreference = "CoQBcQAAAIRf9I4z52kTtz0ia1Gdg-vhxy-xRSFhvLRXsZIqgq_abN93uSXsaQKQAAIk3-9OZrn94HdCEoW7Bwb9SkCPPkQR4V8M0zNxbc0q8dFHD812zZJcvgY2WUfQdOI2PbirKmCTQRkX7QI_FeoYzHhZRIOOuYMh_rdf5Liv2Lt_MMHMEhDWp4MNlq3jxaljO5dUvZeOGhTeqVEjixg-GQ-KUx_mkwm2Scf1gg", Sensor = "false" }));
            return result;
        }

        //proba
        [HttpGet]
        public object PlaceAutocomplete()
        {
            var result = JsonConvert.DeserializeObject<object>(new PlaceAutocompleteApi().PlaceAutocomplete(new PlaceAutocompleteQuery { Input = "Iasi", Sensor = "false", Types = "geocode" }));
            return result;
        }
    }
}
